package demo;


    class Money implements Cloneable{
        public double money=12.25;

        @Override
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        }
    }
    class Student implements Cloneable {
        public String name="张三";
        public Money  m=new Money();

        @Override
        public String toString() {
            return "Student{" +
                    "name='" + name + '\'' +
                    '}';
        }

        @Override
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        }
    }
    public class test {
        public static void main(String[] args)  throws CloneNotSupportedException  {
            Student student1=new Student();
            Student student2=(Student)student1.clone();
            student2.m=(Money)student1.m.clone();
            System.out.println(student1.toString());
            System.out.println(student2.toString());
            System.out.println(student1.m.money);
            System.out.println(student2.m.money);
            student2.m.money=99.0;
            System.out.println(student1.m.money);
            System.out.println(student2.m.money);
            System.out.println(new Student());
        }


    }


